package com.java.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.java.control.AbstractAdminCommandController;
import com.java.control.search.QIndexSearchCond;
import com.java.control.search.QListSearchCond;
import com.java.control.search.SearchStat;
import com.java.control.search.SupplierQuotationSearchCond;
import com.java.entity.Product;
import com.java.entity.QIndex;
import com.java.entity.QList;
import com.java.entity.SupplierQuotation;
import com.java.service.ProductService;
import com.java.service.QuotationService;
import com.java.service.SupplierQuotationService;

/**
 * 产品右边供应商报价信息控制器
 * @author wqf
 * @version  Nov 14, 2011 2:38:40 PM
 */
public class QListController extends AbstractAdminCommandController {
	
	public QListController(){
		this.setCommandClass(QListSearchCond.class);
	}	
	
	private String successView;
	public void setSuccessView(String successView) {
		this.successView = successView;
	}
	
	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
	throws Exception{
		ModelAndView mav=new ModelAndView(this.successView);
		String qid=request.getParameter("qid");
		QListSearchCond searchCond = (QListSearchCond)command;
		SearchStat searchStat = new SearchStat();
		List<QList> List = null;
		QIndex qIndex = null;
		if(null!=qid){
			qIndex = this.quotationService.getQIndexById(Long.parseLong(qid));
			searchCond.setPageSize(10L);
			searchCond.setQid(qIndex.getId());
			searchStat = this.quotationService.getSearchStat(QList.class, searchCond);
			List = this.quotationService.search(QList.class,searchCond,"id desc");						
		}
		mav.addObject("searchStat", searchStat);
		mav.addObject("searchCond", searchCond);
		mav.addObject("qIndex",qIndex);
		mav.addObject("qList", List);
		
		return mav;
	
	}
	
	private QuotationService quotationService;
	
	public QuotationService getQuotationService() {
		return quotationService;
	}

	public void setQuotationService(QuotationService quotationService) {
		this.quotationService = quotationService;
	}

	public String getSuccessView() {
		return successView;
	}


}
